﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Drawing;

namespace OnlineDovizOtomasyonu
{
    public partial class genelayrinti : System.Web.UI.Page
    {
        Fonksiyon Sistem = new Fonksiyon();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack != true)
            {
                int Gun = 1, Ay = 0, Yil = 0;
                DateTime YeniTarih1;
                //Gun = Convert.ToInt32(DateTime.Now.Day)-1;
                Ay = Convert.ToInt32(DateTime.Now.Month);
                Yil = Convert.ToInt32(DateTime.Now.Year);
                YeniTarih1 = Convert.ToDateTime(Gun + "." + Ay + "." + Yil);
                txtTarih1.Value = YeniTarih1;
                txtTarih2.Value = DateTime.Today;
                txtMusteriGroup.SelectedIndex = Convert.ToInt32(Session["webingMG"]);
                txtMusteriKodu.SelectedIndex = Convert.ToInt32(Session["webingMK"]);
                FonksiyonToplam();
                ToplamFormat();
            }

            
            
        }

        protected void txtMusteriKodu_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["webingMK"] = txtMusteriKodu.Value;
            FonksiyonToplam();
            ToplamFormat();
        }

        protected void txtTarih1_DateChanged(object sender, EventArgs e)
        {
            //Session["AyrintiTarih1"] = txtTarih1.Value;
            FonksiyonToplam();
            ToplamFormat();
        }

        protected void txtTarih2_DateChanged(object sender, EventArgs e)
        {
            //Session["AyrintiTarih2"] = txtTarih2.Value;
            FonksiyonToplam();
            ToplamFormat();
        }

        void FonksiyonToplam()
        {
            SqlConnection con = Sistem.baglan();
            SqlCommand komut = new SqlCommand();
            komut.Connection = con;
            komut.CommandText = "SELECT SUM(TTL) AS TLTOPLAM FROM VWTRHTL WHERE TARIH BETWEEN '"+ txtTarih1.Value +"' AND '"+ txtTarih2.Value +"'";
            SqlDataReader dr = komut.ExecuteReader();
            while (dr.Read())
            {
                txtTTl.Text = dr["TLTOPLAM"].ToString();
            }

            SqlConnection con1 = Sistem.baglan();
            SqlCommand komut1 = new SqlCommand();
            komut1.Connection = con1;
            komut1.CommandText = "SELECT SUM(TUSD) AS USDTOPLAM FROM VWTRHUSD WHERE TARIH BETWEEN '" + txtTarih1.Value + "' AND '" + txtTarih2.Value + "'";
            SqlDataReader dr1 = komut1.ExecuteReader();
            while (dr1.Read())
            {
                txtTUSD.Text = dr1["USDTOPLAM"].ToString();
            }

            SqlConnection con2 = Sistem.baglan();
            SqlCommand komut2 = new SqlCommand();
            komut2.Connection = con2;
            komut2.CommandText = "SELECT SUM(TEURO) AS EUROTOPLAM FROM VWTRHEURO WHERE TARIH BETWEEN '" + txtTarih1.Value + "' AND '" + txtTarih2.Value + "'";
            SqlDataReader dr2 = komut2.ExecuteReader();
            while (dr2.Read())
            {
                txtTEURO.Text = dr2["EUROTOPLAM"].ToString();
            }

            SqlConnection con3 = Sistem.baglan();
            SqlCommand komut3 = new SqlCommand();
            komut3.Connection = con3;
            komut3.CommandText = "SELECT SUM(TSAR) AS SARTOPLAM FROM VWTRHSAR WHERE TARIH BETWEEN '" + txtTarih1.Value + "' AND '" + txtTarih2.Value + "'";
            SqlDataReader dr3 = komut3.ExecuteReader();
            while (dr3.Read())
            {
                txtTSAR.Text = dr3["SARTOPLAM"].ToString();
            }

            SqlConnection con4 = Sistem.baglan();
            SqlCommand komut4 = new SqlCommand();
            komut4.Connection = con4;
            komut4.CommandText = "SELECT SUM(TSRY) AS SRYTOPLAM FROM VWTRHSRY WHERE TARIH BETWEEN '" + txtTarih1.Value + "' AND '" + txtTarih2.Value + "'";
            SqlDataReader dr4 = komut4.ExecuteReader();
            while (dr4.Read())
            {
                txtTSRY.Text = dr4["SRYTOPLAM"].ToString();
            }

        }

        void ToplamFormat()
        {
            if (Convert.ToDecimal(txtTTl.Text) > 0)
            {
                txtTTl.BackColor = Color.FromArgb(187, 255, 187);
            }
            else
            {
                txtTTl.BackColor = Color.FromArgb(255, 170, 170);
            }
            if (Convert.ToDecimal(txtTUSD.Text) > 0)
            {
                txtTUSD.BackColor = Color.FromArgb(187, 255, 187);
            }
            else
            {
                txtTUSD.BackColor = Color.FromArgb(255, 170, 170);
            }
            if (Convert.ToDecimal(txtTEURO.Text) > 0)
            {
                txtTEURO.BackColor = Color.FromArgb(187, 255, 187);
            }
            else
            {
                txtTEURO.BackColor = Color.FromArgb(255, 170, 170);
            }
            if (Convert.ToDecimal(txtTSAR.Text) > 0)
            {
                txtTSAR.BackColor = Color.FromArgb(187, 255, 187);
            }
            else
            {
                txtTSAR.BackColor = Color.FromArgb(255, 170, 170);
            }
            if (Convert.ToDecimal(txtTSRY.Text) > 0)
            {
                txtTSRY.BackColor = Color.FromArgb(187, 255, 187);
            }
            else
            {
                txtTSRY.BackColor = Color.FromArgb(255, 170, 170);
            }
        }

        protected void txtMusteriGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["webingMG"] = txtMusteriGroup.Value;
            FonksiyonToplam();
            ToplamFormat();
        }

        protected void btnKapat_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("sistem.aspx");
        }

        public void convertExcel()
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
            HttpContext.Current.Response.Charset = "windows-1254"; //ISO-8859-13 ISO-8859-9  windows-1254

            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
            HttpContext.Current.Response.AppendHeader("content-disposition", string.Format("attachment; filename={0}", "deneme.xls"));

            string sep = "";
            HttpContext.Current.Response.Write(string.Format("{0}ID", sep));
            sep = "\t";
            HttpContext.Current.Response.Write(string.Format("{0}AD", sep));
            HttpContext.Current.Response.Write(string.Format("{0}SOYAD", sep));
            HttpContext.Current.Response.Write(string.Format("{0}İŞYERİ ADRESİ", sep));

            HttpContext.Current.Response.Write("\n");

            for (int i = 1; i <= 40; i++)
            {
                HttpContext.Current.Response.Write(string.Format("veri{0}{1}", i.ToString(), sep));

                if (i % 4 == 0)
                {
                    HttpContext.Current.Response.Write("\n");
                }
            }

            HttpContext.Current.Response.End();
        }

        private void ExporttoExcel()
        {
            decimal TLToplam = 0;
            decimal USDToplam = 0;
            decimal EUROToplam = 0;
            decimal SARToplam = 0;
            decimal SRYToplam = 0;
            decimal TLVToplam = 0;
            decimal USDVToplam = 0;
            decimal EUROVToplam = 0;
            decimal SARVToplam = 0;
            decimal SRYVToplam = 0;
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            //HttpContext.Current.Response.ContentType = "application/ms-word";
            HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename="+ txtMusteriKodu.Text +"-Ayrıntı-Hareket-Raporu.xls");
            // HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=Reports.doc");
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
            HttpContext.Current.Response.Charset = "windows-1254"; //ISO-8859-13 ISO-8859-9  windows-1254

            HttpContext.Current.Response.Write("<table width='600px' style='width:600px;' border='1'>");
            HttpContext.Current.Response.Write("<tr>");
            HttpContext.Current.Response.Write("<td colspan='4' width='600px' align='center'><font style='font-size:9pt; color:#000; font-family:Calibri;'>" + DateTime.Now.ToLongDateString() + "</font><br><font style='font-size:12.0pt; color:#000; font-family:Calibri;'><B>" + txtMusteriKodu.Text + " HAREKET RAPORU</B></font></td></tr>");
            HttpContext.Current.Response.Write("<tr>");
            HttpContext.Current.Response.Write("<td colspan='4' width='600px' align='center'><font style='font-size:10.0pt; color:#06F; font-family:Calibri;'><b>ALACAK HAREKETLERİ</b></font></td>");
            HttpContext.Current.Response.Write("</tr>");
            HttpContext.Current.Response.Write("<tr>");
            HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#06F; font-family:Calibri;'>TARİH</font></td>");
            HttpContext.Current.Response.Write("<td width='40px' style='width:40px;'><font style='font-size:10.0pt; color:#06F; font-family:Calibri;'>CİNSİ</font></td>");
            HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#06F; font-family:Calibri;'>TUTAR</font></td>");
            HttpContext.Current.Response.Write("<td width='410px' style='width:410px;'><font style='font-size:10.0pt; color:#06F; font-family:Calibri;'>AÇIKLAMA</font></td>");
            HttpContext.Current.Response.Write("</tr>");
            for (int i = 0; i < listeAlacakTL.VisibleRowCount; i++)
            {
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeAlacakTL.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                HttpContext.Current.Response.Write("<td width='40px' style='width:40px;' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>TL</font></td>");
                HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeAlacakTL.GetRowValues(i, new string[] { "TL" })) + "<font></td>");
                HttpContext.Current.Response.Write("<td width='410' style='width:410px;'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeAlacakTL.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                HttpContext.Current.Response.Write("</tr>");
                TLToplam += Convert.ToDecimal(listeAlacakTL.GetRowValues(i, new string[] { "TL" }));
            }
            if (listeAlacakTL.VisibleRowCount > 0)
            {
                HttpContext.Current.Response.Write("<tr><td bgcolor='#0099FF' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + TLToplam + " TL</font></td></tr>");
            }
            
            for (int i = 0; i < listeAlacakUSD.VisibleRowCount; i++)
            {
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeAlacakUSD.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>USD</font></td>");
                HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeAlacakUSD.GetRowValues(i, new string[] { "USD" })) + "<font></td>");
                HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeAlacakUSD.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                HttpContext.Current.Response.Write("</tr>");
                USDToplam += Convert.ToDecimal(listeAlacakUSD.GetRowValues(i, new string[] { "USD" }));
            }
            if (listeAlacakUSD.VisibleRowCount > 0)
            {
                HttpContext.Current.Response.Write("<tr><td bgcolor='#0099FF' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + USDToplam + " USD</font></td></tr>");
            }
                for (int i = 0; i < listeAlacakEURO.VisibleRowCount; i++)
            {
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeAlacakEURO.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>EURO</font></td>");
                HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeAlacakEURO.GetRowValues(i, new string[] { "EURO" })) + "<font></td>");
                HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeAlacakEURO.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                HttpContext.Current.Response.Write("</tr>");
                EUROToplam += Convert.ToDecimal(listeAlacakEURO.GetRowValues(i, new string[] { "EURO" }));
            }
                if (listeAlacakEURO.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#0099FF' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + EUROToplam + " EURO</font></td></tr>");
                }
                for (int i = 0; i < listeAlacakSAR.VisibleRowCount; i++)
            {
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeAlacakSAR.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>SAR</font></td>");
                HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeAlacakSAR.GetRowValues(i, new string[] { "SAR" })) + "<font></td>");
                HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeAlacakSAR.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                HttpContext.Current.Response.Write("</tr>");
                SARToplam += Convert.ToDecimal(listeAlacakSAR.GetRowValues(i, new string[] { "SAR" }));
            }
                if (listeAlacakSAR.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#0099FF' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + SARToplam + " SAR</font></td></tr>");
                }
                for (int i = 0; i < listeAlacakSRY.VisibleRowCount; i++)
            {
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeAlacakSRY.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>SRY</font></td>");
                HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeAlacakSRY.GetRowValues(i, new string[] { "SRY" })) + "<font></td>");
                HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeAlacakSRY.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                HttpContext.Current.Response.Write("</tr>");
                SRYToplam += Convert.ToDecimal(listeAlacakSRY.GetRowValues(i, new string[] { "SRY" }));
            }
                if (listeAlacakSRY.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#0099FF' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + SRYToplam + " SRY</font></td></tr>");
                }

                HttpContext.Current.Response.Write("<tr><td colspan='4' border='0'></td></tr>");
            //Verecek
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td colspan='4' width='600px' style='border-color:#FFF;' align='center'><font style='font-size:10.0pt; color:#C00; font-family:Calibri;'><b>VERECEK HAREKETLERİ</b></font></td>");
                HttpContext.Current.Response.Write("</tr>");
                HttpContext.Current.Response.Write("<tr>");
                HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#C00; font-family:Calibri;'>TARİH</font></td>");
                HttpContext.Current.Response.Write("<td width='40px' style='width:40px;'><font style='font-size:10.0pt; color:#C00; font-family:Calibri;'>CİNSİ</font></td>");
                HttpContext.Current.Response.Write("<td width='75px' style='width:75px;'><font style='font-size:10.0pt; color:#C00; font-family:Calibri;'>TUTAR</font></td>");
                HttpContext.Current.Response.Write("<td width='410px' style='width:410px;'><font style='font-size:10.0pt; color:#C00; font-family:Calibri;'>AÇIKLAMA</font></td>");
                HttpContext.Current.Response.Write("</tr>");
                for (int i = 0; i < listeVerecekTL.VisibleRowCount; i++)
                {
                    HttpContext.Current.Response.Write("<tr>");
                    HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeVerecekTL.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                    HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>TL</font></td>");
                    HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeVerecekTL.GetRowValues(i, new string[] { "TL" })) + "<font></td>");
                    HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeVerecekTL.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                    HttpContext.Current.Response.Write("</tr>");
                    TLVToplam += Convert.ToDecimal(listeVerecekTL.GetRowValues(i, new string[] { "TL" }));
                }
                if (listeVerecekTL.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#FF5959' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + TLVToplam + " TL</font></td></tr>");
                }

                for (int i = 0; i < listeVerecekUSD.VisibleRowCount; i++)
                {
                    HttpContext.Current.Response.Write("<tr>");
                    HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeVerecekUSD.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                    HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>USD</font></td>");
                    HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeVerecekUSD.GetRowValues(i, new string[] { "USD" })) + "<font></td>");
                    HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeVerecekUSD.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                    HttpContext.Current.Response.Write("</tr>");
                    USDVToplam += Convert.ToDecimal(listeVerecekUSD.GetRowValues(i, new string[] { "USD" }));
                }
                if (listeVerecekUSD.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#FF5959' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + USDVToplam + " USD</font></td></tr>");
                }
                for (int i = 0; i < listeVerecekEURO.VisibleRowCount; i++)
                {
                    HttpContext.Current.Response.Write("<tr>");
                    HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeVerecekEURO.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                    HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>EURO</font></td>");
                    HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeVerecekEURO.GetRowValues(i, new string[] { "EURO" })) + "<font></td>");
                    HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeVerecekEURO.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                    HttpContext.Current.Response.Write("</tr>");
                    EUROVToplam += Convert.ToDecimal(listeVerecekEURO.GetRowValues(i, new string[] { "EURO" }));
                }
                if (listeVerecekEURO.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#FF5959' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + EUROVToplam + " EURO</font></td></tr>");
                }
                for (int i = 0; i < listeVerecekSAR.VisibleRowCount; i++)
                {
                    HttpContext.Current.Response.Write("<tr>");
                    HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeVerecekSAR.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                    HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>SAR</font></td>");
                    HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeVerecekSAR.GetRowValues(i, new string[] { "SAR" })) + "<font></td>");
                    HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeVerecekSAR.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                    HttpContext.Current.Response.Write("</tr>");
                    SARVToplam += Convert.ToDecimal(listeVerecekSAR.GetRowValues(i, new string[] { "SAR" }));
                }
                if (listeVerecekSAR.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#FF5959' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + SARVToplam + " SAR</font></td></tr>");
                }
                for (int i = 0; i < listeVerecekSRY.VisibleRowCount; i++)
                {
                    HttpContext.Current.Response.Write("<tr>");
                    HttpContext.Current.Response.Write("<td width='25%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:d/M/yyyy}", listeVerecekSRY.GetRowValues(i, new string[] { "TARIH" })) + "</font></td>");
                    HttpContext.Current.Response.Write("<td width='5%' align='center'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>SRY</font></td>");
                    HttpContext.Current.Response.Write("<td width='10%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + String.Format("{0:0.00}", listeVerecekSRY.GetRowValues(i, new string[] { "SRY" })) + "<font></td>");
                    HttpContext.Current.Response.Write("<td width='60%'><font style='font-size:10.0pt; color:#000; font-family:Calibri;'>" + listeVerecekSRY.GetRowValues(i, new string[] { "ACIKLAMA" }) + "<font></td>");
                    HttpContext.Current.Response.Write("</tr>");
                    SRYVToplam += Convert.ToDecimal(listeVerecekSRY.GetRowValues(i, new string[] { "SRY" }));
                }
                if (listeVerecekSRY.VisibleRowCount > 0)
                {
                    HttpContext.Current.Response.Write("<tr><td bgcolor='#FF5959' colspan='4'>Toplam: <font style='font-size:12.0pt; color:#000; font-family:Calibri;'>" + SRYVToplam + " SRY</font></td></tr>");
                }
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'></td></tr>");
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'><b> Genel Toplam :"+ txtTTl.Text +" TL</b></td></tr>");
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'><b> Genel Toplam :" + txtTUSD.Text + " USD</b></td></tr>");
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'><b> Genel Toplam :" + txtTEURO.Text + " EURO</b></td></tr>");
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'><b> Genel Toplam :" + txtTSAR.Text + " SAR</b></td></tr>");
                HttpContext.Current.Response.Write("<tr><td colspan='4' style='border-color:#FFF;'><b> Genel Toplam :" + txtTSRY.Text + " SRY</b></td></tr>");
                HttpContext.Current.Response.Write("</table>");


            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }

        protected void btnExcel_Click(object sender, EventArgs e)
        {
            ExporttoExcel();
        }
        
    }
}